<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.tss.util.*"%>
<%@page import="com.store.ContractMgr"%>
<%@page import="com.store.Contract"%>
<%@page import="com.jedi.*"%>
<%@page import="java.text.*"%>
<%@include file="../check_login.jsp"%>
<%@include file="../global_var.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String enddate = new SimpleDateFormat("yyyy-MM-dd").format(Calendar
			.getInstance().getTime());
	Calendar calen = Calendar.getInstance();
	calen.setTime(TSSDate.parseDate(enddate));
	calen.add(Calendar.MONTH, -1);
	String begindate = new SimpleDateFormat("yyyy-MM-dd").format(calen.getTime());
	ContractMgr conMgr = new ContractMgr();
	String creator = ParamUtils.getParameter(request, "creator", "");
		String area_id = ParamUtils.getParameter(request, "area_id", "");
	List list = null;
	String begin_date = ParamUtils.getParameter(request, "begin_date",begindate);
	String end_date = ParamUtils.getParameter(request, "end_date",enddate);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>产品合同统计</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

		<link href="style/main.css" rel="stylesheet" type="text/css">
		<script language="javascript" src="js/common.js"></script>
		<script language="javascript">
function clk_task_show(id) {
	right_menu_clk("task_show.jsp?taskid=" + id);
}
</script>
	</head>
	<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
		<table width="95%" border="0" cellpadding="0" cellspacing="0" align="center">
			<tr>
				<td>
					<form name="pageForm" method="post">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td height="100" valign="top" align="center"
									style="padding-top:12px;padding-bottom:10px;">

									<table width="98%" border="0" cellpadding="0" cellspacing="1"
										bgcolor="#FFFFFF">
										<tr bgcolor="#D7D7DB">
											<td height="24" style="padding-left:10px;" colspan="7">
				所在区域： 
                  <select name="area_id" onchange="pageForm.submit();" style="width:80px">
                   <option value="">==全部==</option>
                    <%for(int i=0;i<area_item_info.length;i++){%>
                    <option value="<%=area_item_info[i]%>"<%if (area_id.trim().equals(area_item_info[i])){%> selected<%}%>><%=area_item_info[i]%></option>
                    <%}%>
                  </select>

												&nbsp;&nbsp;统计日期： 从
												<span id="htmlBeginTime">&nbsp;</span> &nbsp; 至 &nbsp;
												<span id="htmlEndTime">&nbsp;</span>
											</td>
											<td align="center" width="10%">
												<input type="submit" class="inputButton" value="确定">
											</td>
										</tr>
										<tr bgcolor="#FFFFFF">
											<td height="15" style="padding-left:10px;" colspan="4">
											</td>
										</tr>
									</table>
									<table width="98%" border="0" cellpadding="0" cellspacing="1"
										bgcolor="#FFFFFF">
										<tr align="center" bgcolor="#858585">
											<td width="30%" height="25">
												<font color="#FFFFFF">名次</font>
											</td>
											<td width="30%">
												<font color="#FFFFFF">登记人</font>
											</td>
											<td width="30%">
												<font color="#FFFFFF">登记合同目数</font>
											</td>
											<td width="30%">
												<font color="#FFFFFF">成本总金额</font>
											</td>
										

										</tr>
										<%
											String otherSQL = " and contype=1 ";
											if (!creator.trim().equals(""))
												otherSQL += " and t.createman = '" + creator.trim() + "'";
											if (!area_id.trim().equals("")) otherSQL += " and t.area = '" + area_id.trim() + "'";
											if (!begin_date.trim().equals(""))
												otherSQL += " and substring(t.createtime for 10) >= '"
												+ begin_date.trim() + "'";
											if (!end_date.trim().equals(""))
												otherSQL += " and substring(t.createtime for 10) <= '"
												+ end_date.trim() + "'";
											String orderField = "";
											int pageSize = 10;
											int pageno = 1;
											String page2 = request.getParameter("mgh");
											if (page2 == null || page2 == "") {
												pageno = 1;
											} else {
												pageno = Integer.parseInt(page2);
											}
											int pageNo = ParamUtils.getIntParameter(request, "page", pageno);
											String pageno1 = String.valueOf(pageNo);
											session.setAttribute("pageno1", pageno1);
											list = conMgr.conState(otherSQL, orderField, pageNo, pageSize);
											
											int total = conMgr.getTotal();
											boolean b = (total % pageSize == 0);
											int pageCount = b ? (total / pageSize) : (total / pageSize + 1);
											if (pageNo > pageCount) {
												pageNo = pageCount;
											}
											if (list != null && list.size() > 0) {
												String bgColor[] = { "#EDEDF0", "#D7D7DB" };
												for (int i = 0; i < list.size(); i++) {
													Contract item = (Contract) list.get(i);
										%>
										<tr align="center" bgcolor="<%=bgColor[i % 2]%>">
											<td height="24">
												<%=item.getOrder()%>
												
											</td>
											<td>
												<%=item.getCreateman_name()%>
											</td>
											<td>
												<%=item.getPreNum()%>
											</td>
											<td>
												<%=item.getTotFee()%>
											</td>
											
										</tr>
										<%
										}
										%>
									</table>
									<table width="100%" border="0" cellpadding="0" cellspacing="0"
										background="images/page_img/page_bk.gif">
										<tr height="32" align="center" valign="bottom">
											<td width="5%">

											</td>
											<td height="35" align="right" style="padding-right:10px;"
												valign="bottom" id="pannelPageInfo">
												&nbsp;
											</td>
										</tr>
									</table>
									<script language="javascript">
            pannelPageInfo.innerHTML = getPageInfo(<%=total%>,<%=pageSize%>,<%=pageNo%>,5,'images/page_img','pageForm');
            </script>
									<%
									} else {
									%>
								
						</table>
						<table width="95%" border="0" cellpadding="4" cellspacing="1"
							bgcolor="#FFFFFF">
							<tr>
								<td height="60" align="center">
									目前没有任何信息!
								</td>
							</tr>
						</table>
						<%
						}
						%>
					</form>
				</td>
			</tr>
		</table>

		<script language="javascript">
	htmlBeginTime.innerHTML = showCalenderInput("begin_date","pageForm","<%=begin_date%>",1);
	htmlEndTime.innerHTML = showCalenderInput("end_date","pageForm","<%=end_date%>",1);
</script>
	</body>
</html>
